#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

from common.const import SubJobStatusEnum
from informix.service.restore.restorebase import RestoreBase


class SingleRestore(RestoreBase):
    def __init__(self, job_manager, param_obj):
        super(SingleRestore, self).__init__(job_manager, param_obj)

    def restore(self):
        """
        执行恢复子任务
        """
        self.restore_base()
        self.start_single_instance()

    def restore_pre_instance(self):
        return self.restore_pre()

    def start_single_instance(self):
        if self.return_result.task_status == SubJobStatusEnum.COMPLETED:
            self.start_instance()
